﻿namespace HuaWei.Report
{
    using DevExpress.XtraBars.Docking;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using DevExpress.XtraEditors.Repository;
    using DevExpress.XtraReports.UI;
    using DevExpress.XtraTab;
    using DevExpress.XtraTreeList;
    using DevExpress.XtraTreeList.Columns;
    using HauWei.RepUtils;
    using HuaWei.CommClass;
    using HuaWei.Common;
    using HuaWei.DAI;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.IO;
    using System.Windows.Forms;

    public class FrmJLRep : Form
    {
        private bool _flag;
        private string _str = (GParams.APP_PATH + @"RepFile\");
        private HuaWei.Common.dataSets1 dataSets1;
        private DockManager dockManager;
        private DockPanel dockPanel1;
        private ControlContainer dockPanel1_Container;
        private IContainer icontainer = null;
        private IDataAccess idataAccess;
        private PanelControl panelControl6;
        private Panel plReport;
        private PreviewControl previewControl1;
        private QCInfo qcinfo;
        private RepositoryItemImageComboBox repositoryItemImageComboBox2;
        private TreeListColumn tlcEMC;
        private TreeList trRepInfo;
        private TreeListColumn vroAaJyIa;
        private XtraTabControl xtraTabControl1;

        public FrmJLRep()
        {
            this.InitializeComponent();
        }

        protected override void DefWndProc(ref Message m)
        {
            if ((m.Msg == 0x62) || (m.Msg == 0x60))
            {
                this.method();
            }
            else
            {
                base.DefWndProc(ref m);
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.icontainer != null))
            {
                this.icontainer.Dispose();
            }
            base.Dispose(disposing);
        }

        private void FrmJLRep_Load(object sender, EventArgs e)
        {
            this.method();
        }

        private void InitializeComponent()
        {
            this.icontainer = new Container();
            this.panelControl6 = new PanelControl();
            this.xtraTabControl1 = new XtraTabControl();
            this.trRepInfo = new TreeList();
            this.vroAaJyIa = new TreeListColumn();
            this.tlcEMC = new TreeListColumn();
            this.repositoryItemImageComboBox2 = new RepositoryItemImageComboBox();
            this.dockManager = new DockManager(this.icontainer);
            this.dockPanel1 = new DockPanel();
            this.dockPanel1_Container = new ControlContainer();
            this.plReport = new Panel();
            this.previewControl1 = new PreviewControl();
            this.dataSets1 = new HuaWei.Common.dataSets1();
            this.panelControl6.BeginInit();
            this.panelControl6.SuspendLayout();
            this.xtraTabControl1.BeginInit();
            this.trRepInfo.BeginInit();
            this.repositoryItemImageComboBox2.BeginInit();
            this.dockManager.BeginInit();
            this.dockPanel1.SuspendLayout();
            this.dockPanel1_Container.SuspendLayout();
            this.plReport.SuspendLayout();
            this.dataSets1.BeginInit();
            base.SuspendLayout();
            this.panelControl6.Controls.Add(this.xtraTabControl1);
            this.panelControl6.Dock = DockStyle.Top;
            this.panelControl6.Location = new Point(200, 0);
            this.panelControl6.Name = "panelControl6";
            this.panelControl6.Size = new Size(0x35f, 30);
            this.panelControl6.TabIndex = 0x12;
            this.xtraTabControl1.AllowDrop = true;
            this.xtraTabControl1.Dock = DockStyle.Top;
            this.xtraTabControl1.Location = new Point(2, 2);
            this.xtraTabControl1.Name = "xtraTabControl1";
            this.xtraTabControl1.Size = new Size(0x35b, 0x1c);
            this.xtraTabControl1.TabIndex = 12;
            this.xtraTabControl1.SelectedPageChanged += new TabPageChangedEventHandler(this.xtraTabControl1_SelectedPageChanged);
            this.trRepInfo.Columns.AddRange(new TreeListColumn[] { this.vroAaJyIa, this.tlcEMC });
            this.trRepInfo.Dock = DockStyle.Fill;
            this.trRepInfo.ImageIndexFieldName = "";
            this.trRepInfo.Location = new Point(0, 0);
            this.trRepInfo.Name = "trRepInfo";
            this.trRepInfo.BeginUnboundLoad();
            this.trRepInfo.AppendNode(new object[] { "中期价款支付表(支表一)", "REP21" }, -1);
            this.trRepInfo.AppendNode(new object[] { "工程清单计量汇总表(支表三)", "REP03" }, -1);
            this.trRepInfo.AppendNode(new object[] { "工程变更计量汇总表(支表四)", "REP04" }, -1);
            this.trRepInfo.AppendNode(new object[] { "中间计量表", "REP11" }, -1);
            //this.trRepInfo.AppendNode(new object[] { "扣回动员预付款一览表", "REP10" }, -1);
            //this.trRepInfo.AppendNode(new object[] { "扣回材料设备预付款一览表", "REP09" }, -1);
            this.trRepInfo.EndUnboundLoad();
            this.trRepInfo.OptionsBehavior.Editable = false;
            this.trRepInfo.OptionsView.ShowColumns = false;
            this.trRepInfo.OptionsView.ShowIndicator = false;
            this.trRepInfo.OptionsView.ShowRoot = false;
            this.trRepInfo.ParentFieldName = "PID";
            this.trRepInfo.PreviewFieldName = "MC";
            this.trRepInfo.RepositoryItems.AddRange(new RepositoryItem[] { this.repositoryItemImageComboBox2 });
            this.trRepInfo.Size = new Size(0xc2, 0x1ef);
            this.trRepInfo.TabIndex = 0;
            this.trRepInfo.TreeLineStyle = LineStyle.None;
            this.trRepInfo.DoubleClick += new EventHandler(this.trRepInfo_DoubleClick);
            this.vroAaJyIa.Caption = "MC";
            this.vroAaJyIa.FieldName = "MC";
            this.vroAaJyIa.Name = "tlcMC";
            this.vroAaJyIa.Visible = true;
            this.vroAaJyIa.VisibleIndex = 0;
            this.vroAaJyIa.Width = 200;
            this.tlcEMC.Caption = "EMC";
            this.tlcEMC.FieldName = "EMC";
            this.tlcEMC.Name = "tlcEMC";
            this.repositoryItemImageComboBox2.AutoHeight = false;
            this.repositoryItemImageComboBox2.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.repositoryItemImageComboBox2.Items.AddRange(new ImageComboBoxItem[] { new ImageComboBoxItem("", "1", 1), new ImageComboBoxItem("", "2", 5), new ImageComboBoxItem("", "3", 11) });
            this.repositoryItemImageComboBox2.Name = "repositoryItemImageComboBox2";
            this.dockManager.Form = this;
            this.dockManager.RootPanels.AddRange(new DockPanel[] { this.dockPanel1 });
            this.dockManager.TopZIndexControls.AddRange(new string[] { "DevExpress.XtraBars.BarDockControl", "DevExpress.XtraBars.StandaloneBarDockControl", "System.Windows.Forms.StatusBar", "DevExpress.XtraBars.Ribbon.RibbonStatusBar", "DevExpress.XtraBars.Ribbon.RibbonControl" });
            this.dockPanel1.Controls.Add(this.dockPanel1_Container);
            this.dockPanel1.Dock = DockingStyle.Left;
            this.dockPanel1.ID = new Guid("914877a1-53f8-4176-927a-fcfb2c7980e5");
            this.dockPanel1.Location = new Point(0, 0);
            this.dockPanel1.Name = "dockPanel1";
            this.dockPanel1.Options.ShowCloseButton = false;
            this.dockPanel1.OriginalSize = new Size(200, 200);
            this.dockPanel1.Size = new Size(200, 0x20b);
            this.dockPanel1.Text = "报表名称";
            this.dockPanel1_Container.Controls.Add(this.trRepInfo);
            this.dockPanel1_Container.Location = new Point(3, 0x19);
            this.dockPanel1_Container.Name = "dockPanel1_Container";
            this.dockPanel1_Container.Size = new Size(0xc2, 0x1ef);
            this.dockPanel1_Container.TabIndex = 0;
            this.plReport.Controls.Add(this.previewControl1);
            this.plReport.Dock = DockStyle.Fill;
            this.plReport.Location = new Point(200, 30);
            this.plReport.Name = "plReport";
            this.plReport.Size = new Size(0x35f, 0x1ed);
            this.plReport.TabIndex = 20;
            this.previewControl1.Dock = DockStyle.Fill;
            this.previewControl1.FileName = null;
            this.previewControl1.Location = new Point(0, 0);
            this.previewControl1.Name = "previewControl1";
            this.previewControl1.RepDs = this.dataSets1;
            this.previewControl1.Report = null;
            this.previewControl1.Size = new Size(0x35f, 0x1ed);
            this.previewControl1.TabIndex = 0;
            this.dataSets1.DataSetName = "dataSets1";
            this.dataSets1.SchemaSerializationMode = SchemaSerializationMode.IncludeSchema;
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            base.ClientSize = new Size(0x427, 0x20b);
            base.Controls.Add(this.plReport);
            base.Controls.Add(this.panelControl6);
            base.Controls.Add(this.dockPanel1);
            base.Name = "FrmJLRep";
            this.Text = "报表打印";
            base.Load += new EventHandler(this.FrmJLRep_Load);
            this.panelControl6.EndInit();
            this.panelControl6.ResumeLayout(false);
            this.xtraTabControl1.EndInit();
            this.trRepInfo.EndInit();
            this.repositoryItemImageComboBox2.EndInit();
            this.dockManager.EndInit();
            this.dockPanel1.ResumeLayout(false);
            this.dockPanel1_Container.ResumeLayout(false);
            this.plReport.ResumeLayout(false);
            this.dataSets1.EndInit();
            base.ResumeLayout(false);
        }

        private void lquywmUul(DataSet dataSet, string _str1)
        {
            dataSet.Clear();
            string qCID = this.qcinfo.QCID;
            string exeStr = "";
            exeStr = string.Format("select  * from XMJBXX where id='{0}'", GParams._XMID);
            dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "XMJBXX"));
            exeStr = string.Format("select  * from ZZJGXX where id='{0}'", GParams._BDID);
            dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "ZZJGXX"));
            exeStr = string.Format("select aa.BDMC,bb.JLMC,aa.BGHTBH from\r\n(select  1 as F,HTDWMC as BDMC,HTBH as BGHTBH from ZZJGXXEX where id='{0}') aa left join \r\n(select 1 as F,HTDWMC as JLMC from ZZJGXXEX where id in (select pid from ZZJGXX where id='{0}')) bb on aa.f=bb.f", GParams._BDID);
            dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "RepXX"));
            exeStr = string.Format("select  * from XMQC where bdid='{0}' and qcid={1}", GParams._BDID, qCID);
            dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "XMQC"));
            if (!_str1.Equals("REP01"))
            {
                if (_str1.Equals("REP02"))
                {
                    exeStr = CHelp.smethod(string.Format(CRepSQL.REP02, GParams._BDID, qCID));
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_ZQZFZS"));
                }
                else if (_str1.Equals("REP21"))
                {
                    exeStr = CHelp.smethod(string.Format(CRepZFJKSQL.SEARCH10, GParams._BDID, qCID));
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_ZQJKZF10"));
                    exeStr = CHelp.smethod(string.Format(CRepZFJKSQL.SEARCH11, GParams._BDID, qCID));
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_ZQJKZF11"));
                    exeStr = CHelp.smethod(string.Format(CRepZFJKSQL.SEARCH12, GParams._BDID, qCID));
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_ZQJKZF12"));
                    exeStr = CHelp.smethod(string.Format(CRepZFJKSQL.SEARCH13, GParams._BDID, qCID));
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_ZQJKZF13"));
                    exeStr = CHelp.smethod(string.Format(CRepZFJKSQL.SEARCH14, GParams._BDID, qCID));
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_ZQJKZF14"));
                    exeStr = CHelp.smethod(string.Format(CRepZFJKSQL.SEARCH15, GParams._BDID, qCID));
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_ZQJKZF15"));
                    exeStr = CHelp.smethod(string.Format(CRepZFJKSQL.SEARCH16, GParams._BDID, qCID));
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_ZQJKZF16"));
                    exeStr = CHelp.smethod(string.Format(CRepZFJKSQL.SEARCH17, GParams._BDID, qCID));
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_ZQJKZF17"));
                    exeStr = CHelp.smethod(string.Format(CRepZFJKSQL.SEARCH18, GParams._BDID, qCID));
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_ZQJKZF18"));
                    exeStr = CHelp.smethod(string.Format(CRepZFJKSQL.SEARCH19, GParams._BDID, qCID));
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_ZQJKZF19"));
                    if (dataSet.Tables["REP_ZQJKZF19"].Rows.Count == 1 && dataSet.Tables["REP_ZQJKZF19"].Rows[0]["hj"] != DBNull.Value)
                    {
                        dataSet.Tables["REP_ZQJKZF19"].Rows[0]["LargeNum"] = RMBCapitalization.smethod(CHelp.ConvertDecimal(dataSet.Tables["REP_ZQJKZF19"].Rows[0]["hj"], 0, 0));
                    }

                    exeStr = CHelp.smethod(string.Format(CRepZFJKSQL.SEARCH20, GParams._BDID, qCID));
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_ZQJKZF20"));
                    exeStr = CHelp.smethod(string.Format(CRepZFJKSQL.SEARCH21, GParams._BDID, qCID));
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_ZQJKZF21"));
                    exeStr = CHelp.smethod(string.Format(CRepZFJKSQL.SEARCH22, GParams._BDID, qCID));
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_ZQJKZF22"));
                    exeStr = CHelp.smethod(string.Format(CRepZFJKSQL.SEARCH31, GParams._BDID, qCID));
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_ZQJKZF2_1"));
                    exeStr = CHelp.smethod(string.Format(CRepZFJKSQL.SEARCH32, GParams._BDID, qCID));
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_ZQJKZF2_2"));
                    exeStr = CHelp.smethod(string.Format(CRepZFJKSQL.SEARCH33, GParams._BDID, qCID));
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_ZQJKZF2_3"));
                }
                else if (_str1.Equals("REP03"))
                {
                    exeStr = string.Format(CRepSQL.REP03, GParams._BDID, qCID);
                    DataSet dsResult = this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_ZQZFZS");

                    exeStr = string.Format(CRepSQL.REP03, GParams._BDID, (Convert.ToInt32(qCID) - 1).ToString());
                    DataSet ds = this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_ZQZFZS");
                    foreach (DataRow dr in dsResult.Tables["REP_ZQZFZS"].Rows)
                    {
                        dr["zjlx"] = dr["QDBH"].ToString().Substring(0, 1);

                        string[] qdbhArr = dr["QDBH"].ToString().Split('-');
                        dr["SubQDBH1"] = qdbhArr[0];
                        dr["SubQDBHLen1"] = qdbhArr[0].Length;
                        if (qdbhArr.Length > 1)
                        {
                            dr["SubQDBH2"] = qdbhArr[1];
                            dr["SubQDBHLen2"] = qdbhArr[1].Length;
                            if (qdbhArr.Length > 2)
                            {
                                dr["SubQDBH3"] = qdbhArr[2];
                                dr["SubQDBHLen3"] = qdbhArr[2].Length;
                                if (qdbhArr.Length > 3)
                                {
                                    dr["SubQDBH4"] = qdbhArr[3];
                                    dr["SubQDBHLen4"] = qdbhArr[3].Length;
                                    if (qdbhArr.Length > 4)
                                    {
                                        dr["SubQDBH5"] = qdbhArr[4];
                                        dr["SubQDBHLen5"] = qdbhArr[4].Length;
                                    }
                                }
                            }
                        }

                        DataRow[] drs = ds.Tables["REP_ZQZFZS"].Select("QDBH='" + dr["QDBH"] + "'");
                        if (drs != null && drs.Length == 1 && drs[0]["bqmjlje"] != DBNull.Value)
                        {
                            dr["sqmjl"] = drs[0]["bqmjl"];
                            dr["sqmjlje"] = drs[0]["bqmjlje"];
                            if (dr["bqmjlje"] != DBNull.Value)
                            {
                                dr["BQJL"] = Convert.ToInt32(dr["bqmjl"]) - Convert.ToInt32(dr["sqmjl"]);
                                dr["bqjlje"] = Convert.ToInt32(dr["bqmjlje"]) - Convert.ToInt32(dr["sqmjlje"]);
                            }
                        }
                        else
                        {
                            dr["sqmjl"] = 0;
                            if (dr["bqmjl"] == DBNull.Value)
                            {
                                dr["sqmjl"] = DBNull.Value;
                            }
                            dr["sqmjlje"] = 0;
                            if (dr["bqmjlje"] == DBNull.Value)
                            {
                                dr["sqmjlje"] = DBNull.Value;
                            }
                            dr["BQJL"] = dr["bqmjl"];
                            dr["bqjlje"] = dr["bqmjlje"];
                        }
                    }

                    DataTable dtResult = dsResult.Tables["REP_ZQZFZS"].Clone();
                    DataRow[] drsOrder = dsResult.Tables["REP_ZQZFZS"].Select("1=1", "SubQDBHLen1,SubQDBH1,SubQDBHLen2,SubQDBH2,SubQDBHLen3,SubQDBH3,SubQDBHLen4,SubQDBH4,SubQDBHLen5,SubQDBH5");
                    foreach (DataRow dr in drsOrder)
                    {
                        dtResult.ImportRow(dr);
                    }
                    dataSet.Tables.Add(dtResult);
                }
                else if (_str1 == "REP04")
                {
                    exeStr = string.Format(CRepSQL.REP04, GParams._BDID, qCID);
                    DataSet dsResult = idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_GCBG");

                    exeStr = string.Format(CRepSQL.REP04, GParams._BDID, (Convert.ToInt32(qCID) - 1).ToString());
                    DataSet ds = idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_GCBG");
                    foreach (DataRow dr in dsResult.Tables["REP_GCBG"].Rows)
                    {
                        string[] qdbhArr = dr["QDBH"].ToString().Split('-');
                        dr["SubQDBH1"] = qdbhArr[0];
                        dr["SubQDBHLen1"] = qdbhArr[0].Length;
                        if (qdbhArr.Length > 1)
                        {
                            dr["SubQDBH2"] = qdbhArr[1];
                            dr["SubQDBHLen2"] = qdbhArr[1].Length;
                            if (qdbhArr.Length > 2)
                            {
                                dr["SubQDBH3"] = qdbhArr[2];
                                dr["SubQDBHLen3"] = qdbhArr[2].Length;
                                if (qdbhArr.Length > 3)
                                {
                                    dr["SubQDBH4"] = qdbhArr[3];
                                    dr["SubQDBHLen4"] = qdbhArr[3].Length;
                                    if (qdbhArr.Length > 4)
                                    {
                                        dr["SubQDBH5"] = qdbhArr[4];
                                        dr["SubQDBHLen5"] = qdbhArr[4].Length;
                                    }
                                }
                            }
                        }

                        DataRow[] drs = ds.Tables["REP_GCBG"].Select("QDBH='" + dr["QDBH"] + "'");
                        if (drs != null && drs.Length == 1 && drs[0]["bqmjlje"] != DBNull.Value)
                        {
                            dr["sqmjl"] = drs[0]["bqmjl"];
                            dr["sqmjlje"] = drs[0]["bqmjlje"];
                            if (dr["bqmjlje"] != DBNull.Value)
                            {
                                dr["BQJL"] = Convert.ToInt32(dr["bqmjl"]) - Convert.ToInt32(dr["sqmjl"]);
                                dr["bqjlje"] = Convert.ToInt32(dr["bqmjlje"]) - Convert.ToInt32(dr["sqmjlje"]);
                            }
                        }
                        else
                        {
                            dr["sqmjl"] = 0;
                            if (dr["bqmjl"] == DBNull.Value)
                            {
                                dr["sqmjl"] = DBNull.Value;
                            }
                            dr["sqmjlje"] = 0;
                            if (dr["bqmjlje"] == DBNull.Value)
                            {
                                dr["sqmjlje"] = DBNull.Value;
                            }
                            dr["BQJL"] = dr["bqmjl"];
                            dr["bqjlje"] = dr["bqmjlje"];
                        }
                    }

                    DataTable dtResult = dsResult.Tables["REP_GCBG"].Clone();
                    DataRow[] drsOrder = dsResult.Tables["REP_GCBG"].Select("1=1", "bglh,SubQDBHLen1,SubQDBH1,SubQDBHLen2,SubQDBH2,SubQDBHLen3,SubQDBH3,SubQDBHLen4,SubQDBH4,SubQDBHLen5,SubQDBH5");
                    foreach (DataRow dr in drsOrder)
                    {
                        dtResult.ImportRow(dr);
                    }
                    dataSet.Tables.Add(dtResult);
                }
                else if (_str1.Equals("REP05"))
                {
                    exeStr = CHelp.smethod(string.Format(CRepSQL.REP05, GParams._BDID, qCID));
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_GCBG"));
                }
                else if (_str1.Equals("REP07"))
                {
                    exeStr = CHelp.smethod(string.Format(CRepSQL.REP07, GParams._BDID, qCID));
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "JGTZMX"));
                }
                else if (_str1.Equals("REP09"))
                {
                    exeStr = CHelp.smethod(string.Format(CRepSQL.REP09, GParams._BDID, qCID));
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "CLYFK"));
                }
                else if (_str1.Equals("REP10"))
                {
                    exeStr = CHelp.smethod(string.Format(CRepSQL.REP10, GParams._BDID, qCID));
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "DYYFK"));
                }
                else if (_str1.Equals("REP11"))
                {
                    exeStr = string.Format(CRepSQL.REP11_1, GParams._BDID, qCID);
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "QDJL_M"));
                    exeStr = string.Format(CRepSQL.REP11_2, GParams._BDID, qCID);
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "QDJL_JSS"));
                    DataTable table = dataSet.Tables["QDJL_M"];
                    DataTable table2 = dataSet.Tables["QDJL_JSS"];
                    foreach (DataRow row in table.Rows)
                    {
                        string str3 = "";
                        int a = 0;
                        table2.DefaultView.RowFilter = "pid='" + row["id"].ToString() + "'";
                        foreach (DataRowView view in table2.DefaultView)
                        {
                            a++;
                            DataRow row2 = view.Row;
                            if (!str3.Equals(""))
                            {
                                int result = 0;
                                Math.DivRem(a, 3, out result);
                                if (result.Equals(1))
                                {
                                    str3 = str3 + "\n";
                                }
                            }
                            string str4 = str3;
                            str3 = str4 + "\r\n     " + row2["BDS"].ToString() + " = " + row2["JSS"].ToString() + " = " + row2["JSJG"].ToString() + "        ";
                        }
                        if (!str3.Equals(""))
                        {
                            row["jss"] = str3;
                        }
                    }
                    if (!(!GParams._JGLX.Equals(JGLX.CBR) || this.qcinfo.QCZT.Equals(1)))
                    {
                        exeStr = CRepSQL.REP11_31;
                    }
                    else
                    {
                        exeStr = CRepSQL.REP11_30;
                    }
                    exeStr = string.Format(exeStr, GParams._BDID, qCID);
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "QDJL_MX"));
                    DataColumn parentColumn = dataSet.Tables["QDJL_M"].Columns["id"];
                    DataColumn childColumn = dataSet.Tables["QDJL_MX"].Columns["pid"];
                    DataRelation relation = new DataRelation("QDJL_M_QDJL_MX", parentColumn, childColumn);
                    dataSet.Relations.Add(relation);
                }
                else if (_str1.Equals("REP12"))
                {
                    exeStr = string.Format(CRepSQL.REP12_1, GParams._BDID, qCID);
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "dtTemp"));
                    exeStr = string.Format(CRepSQL.REP12_2, GParams._BDID, qCID);
                    dataSet.Merge(this.idataAccess.ExecuteDataSet(exeStr, CommandType.Text, "REP_ZFHZB"));
                    DataTable table3 = dataSet.Tables["REP_ZFHZB"];
                    DataTable table4 = dataSet.Tables["dtTemp"];
                    foreach (DataRow row in table3.Rows)
                    {
                        table4.DefaultView.RowFilter = "qdbh='" + row["qdbh"].ToString() + "'";
                        foreach (DataRowView view in table4.DefaultView)
                        {
                            DataRow row4;
                            DataRow row3 = view.Row;
                            if (!row["pzh"].Equals(""))
                            {
                                (row4 = row)["pzh"] = row4["pzh"] + "/";
                            }
                            (row4 = row)["pzh"] = row4["pzh"] + row3["pzbh"].ToString();
                        }
                    }
                }
            }
        }

        private void method()
        {
            this._flag = true;
            this.idataAccess = DBHelp.IniIDA();
            Class28.JvBxsoguG(this.xtraTabControl1, false);
            this.qcinfo = GParams.QCInfo;
            this.xtraTabControl1.SelectedTabPageIndex = CHelp.ConvertInt(this.qcinfo.QCID, 0) - 1;
            if (this.xtraTabControl1.SelectedTabPage != null)
            {
                this.method2(this.xtraTabControl1.SelectedTabPage);
            }
            this._flag = false;
        }

        private void method1(string _str1, QCInfo qcinfo1)
        {
            try
            {
                string path = this._str + _str1;
                DataSet dataSet = new DataSet();
                this.lquywmUul(dataSet, _str1);
                if (!File.Exists(path))
                {
                    File.Copy(this._str + "RepBase.repx", path);
                }
                XtraReport report = null;
                if (_str1.Equals("REP02"))
                {
                    report = new RepBase1();
                    report.Parameters[0].Value = "ddddd";
                }
                else
                {
                    report = XtraReport.FromFile(path, true);
                }
                report.DataSource = dataSet;
                this.previewControl1.RepDs = dataSet;
                this.previewControl1.Report = report;
                this.previewControl1.Report.FillDataSource();
                this.previewControl1.FileName = path;
                //this.previewControl1.SetPrintBarVisible(qcinfo1.QCZT.Equals(1));
                this.previewControl1.SetEditBarVisible(false);
            }
            catch (Exception ex)
            {
                Log.Write(ex.Message);
            }
        }

        private void method2(XtraTabPage xtraTabPage)
        {
            this.qcinfo = (QCInfo)xtraTabPage.Tag;
            if (xtraTabPage.Tag != null)
            {
                if (!this.qcinfo.QCZT.Equals(1))
                {
                    Class39.smethod15(GParams._BDID, this.qcinfo.QCID, GParams._XMID, GParams._YZID, false, true);
                }
                string str = this.trRepInfo.FocusedNode[1].ToString();
                this.method1(str, this.qcinfo);
            }
        }

        private void method3(object sender, EventArgs e)
        {
        }

        private void trRepInfo_DoubleClick(object sender, EventArgs e)
        {
            string str = this.trRepInfo.FocusedNode[1].ToString();
            this.method1(str, this.qcinfo);
            //frmReportDesign frmReportDesign = new frmReportDesign(str, this._str + str, this.qcinfo.QCZT);
            //frmReportDesign.Show();
        }

        private void xtraTabControl1_SelectedPageChanged(object sender, TabPageChangedEventArgs e)
        {
            if (!this._flag && (e.Page != null))
            {
                this.method2(e.Page);
            }
        }
    }
}

